<template>
	<view>
		<view  @click="toPost(item.id)" v-for="(item,index) in postList" :key="index" class="kuang">
			<view style="display: flex;justify-content: space-between;">
				<view style="width: 36%;">
					<image :src="path+strToArr(item.image)[0]" mode="aspectFill" style="width: 100%;height: 100px;border-radius: 4px;"></image>
				</view>
				<view style="width: 60%;">
					<view style="font-size: 16px;height: 30px;">{{item.title}}</view>
					<view style="font-size: 14px;color: red;height: 20px;line-height: 20px;font-weight: 700;">{{item.salary}}</view>
					<view style="width: 100%;">
						<view v-for="(label,i) in strToArr(item.welfare)" :key="i" v-if="i<3" class="label">{{label}}</view>
					</view>
					<view style="font-size: 14px;color: #999999;height: 20px;line-height: 25px;">{{item.type==0?'正式工':'派遣工'}}</view>
				</view>
			</view>
		</view>
		<view style="width: 100%;height: 50px;"></view>
	</view>
</template>

<script>
	import api from '@/static/js/request.js'
	import data from '@/static/js/util.js'
	export default {
		data() {
			return {
				path: api.getPath(),
				postList: [],
				
				pageNo: 1,
				pageSize: 10,
				total: 0,
			}
		},
		onLoad(){
			this.getApplyPostList();
		},
		onReachBottom() {
			if(this.total > this.pageNo * this.pageSize){
				this.pageNo ++;
				this.getPostPage()
			}
		},
		methods: {
			strToArr(str){
				return data.strToArr(str);
			},
			getApplyPostList(){
				let _this = this;
				let user = data.getUser();
				api.getApplyPostList({
					userId: user.id,
					pageNo: this.pageNo,
					pageSize: this.pageSize,
				}).then((res)=>{
					_this.postList = res.data.records;
					_this.total = res.data.total;
				})
			},
			toPost(postId){
				uni.navigateTo({
					url: '/pages/post/post?postId='+postId
				})
			},
		}
	}
</script>

<style>
.label{
		padding: 0 5px;
		background-color: #EDF0F2;
		height: 20px;
		line-height: 20px;
		border-radius: 4px;
		font-size: 12px;
		display: inline-block;
		margin-right: 10px;
	}
</style>
